package com.foton.lotterydomain.activity.service.stateflow.event;

import com.foton.lotterycommon.common.Constants;
import com.foton.lotterycommon.common.Result;
import com.foton.lotterydomain.activity.service.stateflow.AbstractState;
import org.springframework.stereotype.Component;

/**
 * @Author RenPu
 * @Date 2023/12/1 17:51
 * @Version 1.0
 * @Description: 活动开启 -具体实现类
 **/

@Component
public class OpenState extends AbstractState {

    // 开启状态单据，可以执行的流程节点为：审核提审，审核关闭


    @Override
    public Result arraignment(Long activityId, Enum<Constants.ActivityState> currentState) {
        return Result.buildErrorResult("活动开启中不可提审！！！！");
    }

    @Override
    public Result checkPass(Long activityId, Enum<Constants.ActivityState> currentState) {
        return Result.buildErrorResult("活动开启中不可审核通过！！！！");
    }

    @Override
    public Result checkRefuse(Long activityId, Enum<Constants.ActivityState> currentState) {
        return Result.buildErrorResult("活动开启中不可审核拒绝！！！！");
    }

    @Override
    public Result checkRevoke(Long activityId, Enum<Constants.ActivityState> currentState) {
        return Result.buildErrorResult("活动开启中不可撤审！！！！");
    }

    @Override
    public Result open(Long activityId, Enum<Constants.ActivityState> currentState) {
        return Result.buildErrorResult("活动开启中不可开启！！！！");
    }

    @Override
    public Result close(Long activityId, Enum<Constants.ActivityState> currentState) {
        boolean updateResult = activityRepository.alterStatus(activityId, currentState, Constants.ActivityState.CLOSE);
        return updateResult ? Result.buildResult(Constants.ResponseCode.SUCCESS.getCode(), "活动关闭完成！！！！") : Result.buildErrorResult("活动状态变更失败");

    }

    @Override
    public Result doing(Long activityId, Enum<Constants.ActivityState> currentState) {
        boolean updateResult = activityRepository.alterStatus(activityId, currentState, Constants.ActivityState.DOING);
        return updateResult ? Result.buildResult(Constants.ResponseCode.SUCCESS.getCode(), "活动执行中状态变更完成！！！！") : Result.buildErrorResult("活动状态变更失败");

    }
}
